package com.weilx959.spt.plugin.e2sp;

import com.weilx959.spt.core.constants.ThemeEnum;
import com.weilx959.spt.core.interfaces.Controller;
import com.weilx959.spt.core.interfaces.SPTPlugin;
import com.weilx959.spt.core.utils.FXMLUtil;
import com.weilx959.spt.plugin.e2sp.constant.ExcelToSqlConstants;
import com.weilx959.spt.plugin.e2sp.controller.SqlToExcelController;
import com.weilx959.spt.plugin.e2sp.utils.ResourceBundleUtil;
import javafx.scene.Node;

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.ResourceBundle;

/**
 * SQL to Excel Plugin Implementation
 *
 * @author weilx
 * @since 2024年7月6日
 */
public class Sql2ExcelPluginImpl implements SPTPlugin {
    private final SqlToExcelController controller;

    private final ResourceBundle bundle = ResourceBundleUtil.get();

    public Sql2ExcelPluginImpl() {
        controller =  FXMLUtil.getController(this.getClass(), ExcelToSqlConstants.SQL_TO_EXCEL_VIEW, bundle);
    }

    @Override
    public String getID() {
        return "8f28e7b1-c61c-4fc7-b6fb-a63c24b8f035";
    }

    @Override
    public String getName() {
        return bundle.getString("s2e.plugin.name");
    }

    @Override
    public String getDescription() {
        return bundle.getString("s2e.plugin.description");
    }

    @Override
    public String getVersion() {
        return bundle.getString("s2e.plugin.version");
    }

    @Override
    public String getAuthor() {
        return bundle.getString("s2e.plugin.author");
    }

    @Override
    public Controller getController() {
        return controller;
    }

    @Override
    public Node getView() {
        return controller.getRootPane();
    }

    @Override
    public List<String> getStylesheets(ThemeEnum theme) {
        if (Objects.isNull(theme)) {
            return Collections.emptyList();
        }
        return switch (theme) {
            case DARK -> List.of("com/weilx959/spt/plugin/e2sp/theme/dark.css");
            case LIGHT -> List.of("com/weilx959/spt/plugin/e2sp/theme/light.css");
            default -> Collections.emptyList();
        };
    }

    @Override
    public String getIconStyle() {
        return "s2e-icon";
    }

    @Override
    public Integer getOrder() {
        return SPTPlugin.super.getOrder() + 2;
    }
}
